/**
 * 
 */
var Attribute = new Class.create({
    initialize : function() {
        this.data = [];
        var data = [];
        data['int'] = true;
        data['varchar'] = true;
        this.data['select'] = data;

        data = [];
        data['varchar'] = true;
        this.data['multiselect'] = data;

        data = [];
        data['int'] = true;
        this.data['checkbox'] = data;

        data = [];
        data['text'] = true;
        this.data['textarea'] = data;

        data = [];
        data['int'] = true;
        data['decimal'] = true;
        data['varchar'] = true;
        this.data['text'] = data;

        $('input_type').observe('change',this._changeInput.bind(this));
    },

    _changeInput : function(event) {
        var element = event.element();
        var options = $('backend_type').childElements();
        $('backend_type').value = '';

        options.each(function(el){
            if(
                typeof(this.data[element.value][el.value]) == 'undefined' || 
                this.data[element.value][el.value] === null
            ) {
                if(el.value!='') {
                    el.addClassName('display-no');
                }
                
            } else {
                if(el.hasClassName('display-no')) {
                    el.removeClassName('display-no');
                }
            }
        }.bind(this));
    }
});